package obth;

import java.util.Scanner;
import java.util.concurrent.BlockingQueue;

public class UserThread implements Runnable {
    private Scanner scanner ;
    private BlockingQueue<PageEvent> msgQueue;

    public UserThread(BlockingQueue<PageEvent> topic_event) {
        msgQueue = topic_event;
        this.scanner = new Scanner(System.in);
    }

    @Override
    public void run() {

        while (true){
            String s = scanner.nextLine();
            int k = 0;
            try {
                k= Integer.parseInt(s);
            }catch (Exception e){
                k=100;
            }
            UserPageEvent userPageEvent = new UserPageEvent(k);
            try {
                msgQueue.put(userPageEvent);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            Tool.debug(userPageEvent);
        }
    }
}
